package com.letere.config;

import com.letere.Interceptor.JwtInterceptor;
import com.letere.bean.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author letere
 * @create 2021-02-09 18:19
 */
@EnableSwagger2
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //资源路径映射
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**").addResourceLocations("file:" + "D:/WorkSpace/workspace-idea/workspace01/毕业设计/博客-后端/src/main/resources/files/");
        registry.addResourceHandler("/about/**").addResourceLocations("file:" + "D:/WorkSpace/workspace-idea/workspace01/毕业设计/博客-后端/src/main/resources/about/");
    }

    //拦截器拦截
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("/user/auth");
    }

}
